home *** CD-ROM | disk | FTP | other *** search
- .H:
- .H:
- .H: Charles G. Nemer CIS 166
- .H: WINDOW FUNCTIONS
- .H:
- .H:
- .N:34
- .F: Page.$$$
-
-
-
- /*****************************************************************************/
- /* This is to show you what you can do with windows */
- /* written by Charles G. Nemer to demostrate windows functions writen by same*/
- /* 4538 Westlake Dr. */
- /* Garland TX. 75043 */
- /* 214 226 9364 */
- /* ver 1 10-87 */
- /*****************************************************************************/
-
-
- #define TRUE -1
- #define FALSE 0
-
- char w_for_retrace;
-
- void intr(int,struct REGPACK*);
- int int86(int,union REGS*,union REGS*);
-
- /* #include <stdarg.h>*/
- #include <stdio.h>
- #include <alloc.h>
- #include <dos.h>
- #include <ctype.h>
- #include <conio.h>
- #include <ctype.h>
- #include <screen.h>
- /* #include "windo1.c" */
-
- union REGS regs;
-
- unsigned short y,yes,rb=10,cb=20,re=20,ce=50,bd=1,bdc=0x70,size,z,x,
- not_done,cl=0x70,done,bdcx,clx,rb1,cb1,re1,ce1,wnumber,
- wc;
-
- char buffer[134],bdcolor,
- c,ch[20],buff1[5],buff2[5],buff3[5],buff4[5];
-
- char *test="abcdefghijklmnopqrstuvwxyz\0";
-
- struct time t_o;
-
- /*****************************************************************************/
- /* function to check if ASCII passed is HEX and if it is make HEX integer */
- /* if it is not it returns 0 */
- /*****************************************************************************/
-
- int hex_int(int c)
- {
- if(isxdigit(c)) /* if HEX */
- {
- if(c>='0' && c<='9') return(c & 0x0f); /* if 0-9 */
- if((c>='A' && c<='F')||(c>='a' && c<='f')) /* if a-d or A-D */
- return((c & 0x0f)+0x09);
- }/* end of if*/
- return(0); /* if not hex return 0*/
- }/* end of hex it*/
-
- /*****************************************************************************/
- /* function wait for key pressed and check if yes or no it will wait untill */
- /* key press and y or n is entered */
- /*****************************************************************************/
-
- int answer_y_n()
- {
- int c;
- do
- {
- while(!kbhit());
- c=getch();
- c=toupper(c);
- }
- while((c!='Y')&&(c!='N'));
- return(c);
- }
-
- /*****************************************************************************/
- /* first demostration of the use of windows */
- /* This demostration is to show you how to make a window and help you select */
- /* the color and border. It also demostrates how to read and write to a */
- /* window. */
- /*****************************************************************************/
-
- void demo1()
- {
- extern unsigned short scanstart,scanstop;
- set_color(BBLACK|WHITE); /* set the color for wprintf()*/
- wnumber=window(0,0,15,79,2,(BBLACK|LIGHT|RED)); /* make window*/
- titlef(" DEMO of WINDOWS ",0x4b);
- set_color(BBLACK|WHITE); wprintf("\n This is a");
- set_color(BBLACK|LIGHT|BLUE); wprintf(" DEMOSTRATION");
- set_color(BBLACK|WHITE); wprintf(" of what you can do with windows. \n");
- wprintf(" Do you see snow Y/N : ");
- buff1[1]=0;
- window(13,35,17,50,10,0x70);
- titlef(" CLOCK ",0x70);
- cursoroff(); /* turn cursor off*/
- do
- {
- do /* write to screen and check for snow*/
- {
- set_snow(FALSE); /* set for fast write*/
- wgoto(1,1);
- gettime(&t_o); /* get time*/
- wprintf("%02d:%02d:%02d::%02d ",t_o.ti_hour,t_o.ti_min,t_o.ti_sec,t_o.ti_hund);
- /* wprintf(ch); write formatted time to window*/
- }
- while(!kbhit()); /* check for key pressed*/
- buff1[0]=getch(); /* get input*/
- buff1[0]=toupper(buff1[0]); /* upper case input*/
- } /* check for Y or N */
- while((buff1[0]!='Y')&&(buff1[0]!='N'));
- delete_window(0);
- wgoto(2,52);
- cursoron();
- wprintf(buff1);
- if((buff1[0]=='Y')||(buff1[0]=='y')) {set_snow(TRUE);}
- wgoto(3,0);
- wprintf(" Next is a demo of window(); \n");
- wprintf(" Press any key :");while(!kbhit());getch();
- clrscr();
- wprintf(" This is a demo of window() \n");
- wprintf(" enter starting row :\n");
- wprintf(" enter starting column :\n");
- wprintf(" enter ending row :\n");
- wprintf(" enter ending column :\n");
- wprintf(" enter border type 0-13 :\n");
- wprintf(" enter border color in HEX background : forground : color=0x\n");
- wprintf(" enter window color in HEX background : forground : color=0x\n");
- wprintf(" are you done Y/N :\n");
- wgoto(1,22);printf("%d",rb); /* and print new */
- wgoto(2,25);printf("%d",cb); /* and print new */
- wgoto(3,20);printf("%d",re); /* and print new */
- wgoto(4,22);printf("%d",ce); /* and print new */
- wgoto(5,26);printf("%d",bd); /* and print new */
- wgoto(6,40);printf("%02X",(bdc&0xf0)); /* and print new */
- wgoto(6,56);printf("%X",(bdc&0x0f)); /* and print new */
- wgoto(6,67);printf("%02X",bdc); /* and print new color */
- wgoto(7,40);printf("%02X",(cl&0xf0)); /* and print new */
- wgoto(7,56);printf("%X",(cl&0x0f)); /* and print new */
- wgoto(7,67);printf("%02X",cl); /* and print new color */
- done=TRUE;
- set_color(cl); /* set color*/
- wnumber=window(rb,cb,re,ce,bd,bdc); /* make window*/
- wprintf(" This is a demo of making a\n");
- wprintf(" window. Like to try ?\n");
- wprintf(" Enter Y/N :");
- if(answer_y_n()=='Y') /* read kbd*/
- {
- delete_window(0);
- clrscr(); /* go to display*/
- while(done)
- {
- not_done=TRUE;
- while(not_done)
- {
- wgoto(0,0);
- titlef(" DEMO of WINDOWS ",0x4b);
- wprintf(" This is a demo ofwnumber=window() \n");
- wprintf(" enter starting row :\n");
- wprintf(" enter starting column :\n");
- wprintf(" enter ending row :\n");
- wprintf(" enter ending column :\n");
- wprintf(" enter border type 0-13 :\n");
- wprintf(" enter border color in HEX background : forground : color=0x\n");
- wprintf(" enter window color in HEX background : forground : color=0x\n");
- wprintf(" are you done Y/N :\n");
- wgoto(1,22);z=freadf(buff1,2); /* get starting row */
- if(z!=0)rb=atoi(buff1);if(rb<0)rb=0;if(rb>24)rb=24; /* check range */
- wgoto(1,22);wprintf(" "); /* clear old */
- wgoto(1,22);printf("%d",rb); /* and print new */
- wgoto(2,25);z=freadf(buff1,2); /* get starting column */
- if(z!=0)cb=atoi(buff1);if(cb<0)cb=0;if(cb>79)cb=79; /* if entered make int from char and check range */
- wgoto(2,25);wprintf(" "); /* clear old */
- wgoto(2,25);printf("%d",cb); /* and print new */
- wgoto(3,20);z=freadf(buff1,2); /* get ending row */
- if(z!=0)re=atoi(buff1);if(re<0)re=0;if(re>24)re=24; /* if entered make int from char and check range */
- wgoto(3,20);wprintf(" "); /* clear old */
- wgoto(3,20);printf("%d",re); /* and print new */
- wgoto(4,23);z=freadf(buff1,2); /* get ending column */
- if(z!=0)ce=atoi(buff1);if(ce<0)ce=0;if(ce>79)ce=79; /* if entered make int from char and check range */
- wgoto(4,23);wprintf(" "); /* clear old */
- wgoto(4,23);printf("%d",ce); /* and print new */
- wgoto(5,26);z=freadf(buff1,2); /* get border type */
- if(z!=0)bd=atoi(buff1); /* if entered make int from char and check range */
- else /* go to next border type */
- {
- bd++; /* next border type */
- if(bd>13) bd=0; /* if on more go to first */
- printf("%d",bd); /* print new border */
- }
- if(bd<0)bd=0;if(bd>13)bd=13; /* if input is out of range make in range */
- wgoto(5,26);wprintf(" "); /* clear old */
- wgoto(5,26);printf("%d",bd); /* and print new */
- wgoto(6,40);z=freadf(buff1,1); /* get border background color */
- if(z!=0) /* if new */
- {
- bdcx=bdc&0x0f;
- bdc=hex_int(buff1[0]); /* if entered make int out of char */
- bdc=bdc<<4|bdcx; /* put in left side of att */
- }
- wgoto(6,40);wprintf(" "); /* clear old */
- wgoto(6,40);printf("%02X",(bdc&0xf0)); /* and print new */
- wgoto(6,56);z=freadf(buff1,1); /* get border forgroung color */
- if(z!=0) /* if new */
- {
- bdcx=bdc&0xf0;
- bdc=hex_int(buff1[0]); /* if entered make int out of char */
- bdc=bdc|bdcx; /* put in left side of att */
- }
- wgoto(6,56);wprintf(" "); /* clear old */
- wgoto(6,56);printf("%X",(bdc&0x0f)); /* and print new */
- wgoto(6,67);printf("%02X",bdc); /* and print new color */
- wgoto(7,40);z=freadf(buff1,1); /* get background color */
- if(z!=0) /* if new */
- {
- clx=cl&0x0f;
- cl=hex_int(buff1[0]); /* if entered make int out of char */
- cl=cl<<4|clx; /* put in left side of att */
-
- }
- wgoto(7,40);wprintf(" "); /* clear old */
- wgoto(7,40);printf("%02X",(cl&0xf0)); /* and print new */
- wgoto(7,56);z=freadf(buff1,1); /* get forgroung color */
- if(z!=0) /* if new */
- {
- clx=cl&0xf0;
- cl=hex_int(buff1[0]); /* if entered make int out of char */
- cl=cl|clx; /* put in left side of att */
- }
- wgoto(7,56);wprintf(" "); /* clear old */
- wgoto(7,56);printf("%X",(cl&0x0f)); /* and print new */
- wgoto(7,67);printf("%02X",cl); /* and print new color */
- wgoto(8,20); /* check to is if done */
- if(answer_y_n()=='Y')
-
- {
- delete_window(0); /* get rid of window*/
- not_done=FALSE;
- }
-
- }
-
- delete_window(0); /* delete window on screen*/
- set_color(cl); /* set color*/
- wnumber=window(rb,cb,re,ce,bd,bdc); /* make window*/
- readf(buffer); /* read kbd*/
- set_color(0x70);
- wnumber=window(15,20,19,60,2,0x07); /* window for question*/
- wprintf(" Do another window Y/N :"); /* another window?*/
-
- if(answer_y_n()=='N')
- {
- delete_window(0);
- delete_window(0);
- done=FALSE; /* if not stop*/
- }
- else
- {
- delete_window(0);
- set_color(BBLACK|WHITE);
- wnumber=window(0,0,15,79,2,(BBLACK|LIGHT|RED));
- }
- }
- }
- else
- {
- delete_window(0);
- delete_window(0);
- }
- }
-
-
- /*****************************************************************************/
- /* This is the second demostration of windows */
- /* It demostrates the use of changing to another window and you can */
- /* write to the window. */
- /*****************************************************************************/
- void demo2()
- {
- set_color(BBLACK|WHITE);
- wnumber=window(0,0,15,79,2,(BBLACK|LIGHT|RED));
- titlef(" A Demostration of WINDOWS ",0x4b);
- wprintf("\n\n\n\n There is some other things that windows let you do.\n");
- set_color(BBLACK|0x03);
- wprintf(" You can change the color of a window any time you like.\n");
- set_color(BBLACK|LIGHT|0x07);wprintf(" Now ");
- set_color(BBLACK|LIGHT|0x06);wprintf("would ");
- set_color(BBLACK|LIGHT|0x05);wprintf("you ");
- set_color(BBLACK|LIGHT|0x04);wprintf("like ");
- set_color(BBLACK|LIGHT|0x03);wprintf("to ");
- set_color(BBLACK|LIGHT|0x02);wprintf("see ");
- set_color(BBLACK|LIGHT|0x01);wprintf("another ");
- set_color(BBLACK|0x07);wprintf("demo, ");
- set_color(BBLACK|0x06);wprintf("it's ");
- set_color(BBLACK|0x05);wprintf("a ");
- set_color(BBLACK|0x04);wprintf("demo\n");
-
- set_color(BBLACK|WHITE);
- wprintf(" on deleteing a window, any window, you must just make \n");
- wprintf(" shure that no other window is on top of it. Enter Y/N :");
-
- if(answer_y_n()=='Y')
- {
-
- set_color(BBLACK|LIGHT|RED); /* set the color of the window*/
- wnumber=window(0,0,10,25,1,0x0f); /* make the window*/
- sprintf(ch,"window %d",wnumber); /* change int to formatted string*/
- titlef(ch,0x7c); /* title the window*/
- set_color(BRED|BLACK); /* set the color of the window*/
- wnumber=window(11,0,21,25,10,0x70); /* make the window*/
- sprintf(ch,"window %d",wnumber); /* change int to formatted string*/
- titlef(ch,0x0F); /* title the window*/
- set_color(BWHITE|BLACK); /* set the color of the window*/
- wnumber=window(0,27,10,45,8,0x0f); /* make the window*/
- sprintf(ch,"window %d",wnumber); /* change int to formatted string*/
- titlef(ch,0x7b); /* title the window*/
- set_color(BBLUE|LIGHT|RED); /* set the color of the window*/
- wnumber=window(11,27,21,45,3,0x70); /* make the window*/
- sprintf(ch,"window %d",wnumber); /* change int to formatted string*/
- titlef(ch,0x79); /* title the window*/
- wnumber=window(0,47,21,77,10,0x0f); /* make the window*/
- sprintf(ch,"window %d",wnumber); /* change int to formatted string*/
- titlef(ch,0x0f); /* title the window*/
- wprintf(" This demo is to show \n");
- wprintf(" how you can write into\n");
- wprintf(" any window.\n");
- wprintf(" Press any key to start");while(!kbhit());getch();
- for(z=1;z<=15;z++) /* write the test data to the windows*/
- {
-
- set_color(BBLACK|RED);
- change_window(2);
- wprintf(test);
- change_window(5);
- wprintf(test);
- change_window(4);
- wprintf(test);
- change_window(3);
- wprintf(test);
- }
- change_window(6);
- clrscr();
- wprintf(" This demo is to show how\n");
- wprintf(" you can delete any window\n");
- wprintf(" in any order.\n");
- wprintf(" going to window 4\n");
- wprintf(" Press any key to start");while(!kbhit());getch();
- wc=(BWHITE|LIGHT|RED);
- change_window(4);
- clrscr();
- wprintf(" Press any key \n");
- wprintf(" to move to \n");
- wprintf(" window 2 and \n");
- wprintf(" delete \n");
- wprintf(" window 3 ");while(!kbhit());getch();
- delete_window(3);
-
- change_window(2);
- clrscr();
- wprintf(" Press any key to\n");
- wprintf(" move to window 5\n");
- wprintf(" and delete \n");
- wprintf(" window 4");while(!kbhit());getch();
- delete_window(4);
-
- change_window(5);
- clrscr();
- wprintf(" Press any key \n");
- wprintf(" to move to \n");
- wprintf(" window 6 and \n");
- wprintf(" delete \n");
- wprintf(" window 2 ");while(!kbhit());getch();
- delete_window(2);
-
- change_window(6);
- clrscr();
- wprintf("\n Press any key to delete\n");
- wprintf(" window 5");while(!kbhit());getch();
- delete_window(5);
-
- }
- for(z=num_of_w();z>=1;z--) /* delete all windows*/
- {delete_window(0);}
- }
-
-
- /*****************************************************************************/
- /* This is the third demostration of windows */
- /* This is to show you all of the borders ( remember that the colors used on */
- /* a border will change it so try different combinations of colors) */
- /*****************************************************************************/
-
- void demo3()
- {
- set_color(BBLACK|WHITE);
- wnumber=window(0,40,15,70,2,(BBLACK|LIGHT|BLUE));
- titlef("\n Demostration of WINDOWS ",0x4b);
- wprintf(" You will see how you can \n");
- wprintf(" write into all windows and\n");
- wprintf(" see some of the window \n");
- wprintf(" borders you can create.\n");
- wprintf(" Like to try Y/N :");
- if(answer_y_n()=='Y')
- {
- rb=0;cb=0;re=5;ce=5;bd=0;
- for(y=1;y<=4;y++) /* make 16 windows*/
- {
-
- for(x=1;x<=4;x++)
- {
- switch (x)
- {
- case 1:
- case 3:
- set_color(0x07);
- bdc=0x70;
- wc=0x7f;
- break;
- case 2:
- case 4:
- set_color(0x70);
- bdc=0x07;
- wc=0x0f;
- break;
- }
- wnumber=window(rb,cb,re,ce,bd,bdc);
- sprintf(ch,"%d",wnumber);
- titlef(ch,wc);
- cb+=9;ce+=9;
- if(bd<=12)bd++;else bd=0;
- }
- rb+=6;re+=6;cb=0;ce=5;
- }
-
- change_window(1);
- clrscr();
- wprintf(" Press any key for demo");
- while(!kbhit());getch();wprintf("\n");
- cursoroff();
- for(z=2;z<=17;z++) /* write into windows to do something*/
- {
- for(y=1;y<=10;y++)
- {
-
- switch(z)
- {
- case 2: change_window(2);wprintf(" this is a test ");
- case 7: change_window(3);wprintf(" this is a test ");
- case 12: change_window(4);wprintf(" this is a test ");
- case 3: change_window(5);wprintf(" this is a test ");
- case 8: change_window(6);wprintf(" this is a test ");
- case 13: change_window(7);wprintf(" this is a test ");
- case 4: change_window(8);wprintf(" this is a test ");
- case 9: change_window(9);wprintf(" this is a test ");
- case 14: change_window(10);wprintf(" this is a test ");
- case 5: change_window(11);wprintf(" this is a test ");
- case 10: change_window(12);wprintf(" this is a test ");
- case 15: change_window(13);wprintf(" this is a test ");
- case 6: change_window(14);wprintf(" this is a test ");
- case 11: change_window(15);wprintf(" this is a test ");
- case 16: change_window(16);wprintf(" this is a test ");
- case 17: change_window(17);wprintf(" this is a test ");
- }
- }
- }
-
- cursoron();
- change_window(1);
- clrscr();
- wprintf("\n\n\n End of demo press any key :");
- while(!kbhit());getch();
- }
- for(z=num_of_w();z>=1;z--)
- {delete_window(0);}
- }
-
-
-
- /*****************************************************************************/
- /* This is the ending demostration of windows */
- /*****************************************************************************/
-
- void ending()
- {
- rb=7;cb=15;re=20;ce=70;
- rb1=(re-rb)/2+rb;
- cb1=(ce-cb)/2+cb;
- re1=rb1;ce1=cb1;
- while((rb1!=rb)||(cb1!=cb)||(re1!=re)||(ce1!=ce))
- {
- wnumber=window(rb1,cb1,re1,ce1,2,0x0f);
- if(rb1!=rb){rb1-=1;}
- if(cb1!=cb){cb1-=1;}
- if(re1!=re){re1+=1;}
- if(ce1!=ce){ce1+=1;}
-
- }
- wnumber=window(rb1,cb1,re1,ce1,2,0x0f);
- wgoto(5,15);
- wprintf(" That all folks !!!!");
- wgoto(7,15);
- wprintf(" press any key :");
- while(!kbhit());getch();
- for(z=num_of_w();z>=1;z--)
- {delete_window(0);}
- set_color(BBLACK|WHITE);
- wnumber=window(8,5,12,75,10,(BBLACK|LIGHT|BLUE));
- titlef(" DEMO of WINDOWS ",0x4b);
- wprintf(" End of the demo, I hope you can use color windows in your programs.\n");
- wprintf(" Press any key :");while(!kbhit());getch();
- }
-
- void intro()
- {
- int w1,w2,w3,w4,w5,w6;
-
- cursoroff();
- set_color(WHITE);
- w1=window(5,5,20,75,2,BBLACK|RED);
- set_color(BLACK);
- w2=window(8,15,17,65,4,BBLACK|WHITE);
- set_color(BBLACK|WHITE);
- w3=window(7,22,13,60,3,BBLACK|WHITE);
- titlef("COLOR WINDOWS",BBLACK|LIGHT|BLUE);
- w4=window(11,30,15,50,1,BBLACK|RED);
- set_color(BWHITE|BLACK);
- w5=window(15,40,22,65,2,BWHITE|BLACK);
- titlef("WINDOWS",BLINK|BWHITE|RED);
- w6=window(0,0,4,79,0,BWHITE|CYAN);
- change_window(w3);
- set_color(BBLACK|WHITE);
- wgoto(1,0);
- wprintf(" WINDOW UTILITY FOR\n");
- wprintf(" TURBO C AND OTHERS\n");
- change_window(w4);
- set_color(BBLACK|WHITE);
- wprintf(" Written in \n");
- wprintf(" Turbo C \n");
- change_window(w5);
- set_color(BWHITE|BLACK);
- wprintf(" by\n");
- wprintf(" Charles G. Nemer\n");
- wprintf(" 4538 Westlake Dr.\n");
- wprintf(" Garland TX. 75043\n");
- wprintf(" 214-226-9364\n");
- change_window(w6);
- set_color(BWHITE|BLACK);
- wprintf(" This window utility package is to show you how windows work. \n");
- wprintf(" All I ask if you use any of this work include my name and address. \n");
- wprintf(" If you think fitting that this work is any good send a donation up to $25. \n");
- wprintf(" press enter : ");
- cursoron();
- freadf(NULL,1);
- for(z=num_of_w();z>=1;z--)
- {delete_window(0);}
- }
-
- main()
- {
- monitor(); /* check mode for screen writes*/
- intro();
- demo1();
- demo2();
- demo3();
- ending();
-
- for(z=num_of_w();z>=1;z--)
- {delete_window(0);}
- }
-
-
-
-
-
-